﻿/*
 * @author: wizardc
 */

using System;
using System.Threading;
using Dou.Timer;

namespace Dou.Sync
{
    /// <summary>
    /// 主线程上下文
    /// </summary>
    public static class MainThreadContext
    {
        private static ThreadSynchronizationContext _context;

        internal static void Init()
        {
            _context = new ThreadSynchronizationContext(Thread.CurrentThread.ManagedThreadId);
            ClockUtil.realTimeClock.AddClient(_context);
        }

        public static void Post(Action action)
        {
            _context.Post(action);
        }

        public static void Post(PostWithParams func, params object[] args)
        {
            _context.Post(func, args);
        }
    }
}
